using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FontDialogBoxProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            fontDialog1.Font  = richTextBox1.SelectionFont;

            if (fontDialog1.ShowDialog() == DialogResult.OK && richTextBox1.SelectionFont != fontDialog1.Font)
            {
                richTextBox1.SelectionFont = fontDialog1.Font;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FontDialog myFD = new FontDialog();
            myFD.Font = richTextBox1.SelectionFont;
            if (myFD.ShowDialog() ==
                DialogResult.OK &&
                richTextBox1.SelectionFont != myFD.Font)
            {
                richTextBox1.SelectionFont = myFD.Font;
            }
        }
    }
}